import React, {Component} from 'react';
import axios from "axios";

class App extends Component {

    getStudents=()=>{
        axios.get('http://localhost:3000/api1/students').then(
            response=>{console.log('成功了',response.data)},
            error=>{console.log('失败了')}


        )
    }

    getCars=()=>{
        axios.get('http://localhost:3000/api2/cars').then(
            response=>{console.log('成功了',response.data)},
            error=>{console.log('失败了')}


        )
    }

    render() {
        return (
            <div>
                <button onClick={this.getStudents}>点我有学生</button>
                <button onClick={this.getCars}>点我有车</button>
            </div>
        );
    }
}

export default App;
